package pit.com.ordermobilesystem.adapter;

import java.util.List;

import pit.com.ordermobilesystem.R;
import pit.com.ordermobilesystem.model.OrderItem;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class OrderItemAdapter  extends ArrayAdapter<OrderItem> {
	private Context mcontext;
	private List<OrderItem> mOrderItemList;
	int Idlayout;

	public OrderItemAdapter(Context context, int layout, List<OrderItem> list) {
		super(context, layout, list);
		this.mcontext = context;
		this.mOrderItemList = list;
		this.Idlayout = layout;
	}

	@Override
	public View getView(int post, View view, ViewGroup parent) {
		// TODO Auto-generated method stub
		OrderItem orderitem = mOrderItemList.get(post);
		if (view == null) {
			LayoutInflater inflater = LayoutInflater.from(mcontext);
			view = inflater.inflate(R.layout.seclectiem, null);
		}
		TextView tv_nameitem = (TextView) view.findViewById(R.id.tv_nameitem);
		tv_nameitem.setText(orderitem.getNameItem());
		TextView tv_priceitem = (TextView) view.findViewById(R.id.tv_priceitem);
		int soluong=orderitem.getNumberItem();
		int tien =(int)orderitem.getPrice();
		tv_priceitem.setText(String.valueOf(soluong)+" x "+String.valueOf(tien)
				+".000 đ = "+String.valueOf(tien*soluong)+".000 đ");
		return view;
	}

}
